home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / hypercar / fun / swllog10.sit / SWL Log 1.0 / stack_-1.xml < prev    next >
Encoding:
Extensible Markup Language  |  1991-03-19  |  12.0 KB  |  16 lines

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE stack PUBLIC "-//Apple, Inc.//DTD stack V 2.0//EN" "" >
  3. <stack>
  4.     <name>in.0</name>
  5.     <id>-1</id>
  6.     <cardCount>94</cardCount>
  7.     <cardID>6049</cardID>
  8.     <listID>31848</listID>
  9.     <cantModify><false /></cantModify>
  10.     <cantDelete><false /></cantDelete>
  11.     <cantAbort><false /></cantAbort>
  12.     <cardSize>
  13.         <width>512</width>
  14.         <height>342</height>
  15.     </cardSize>
  16.     <script>on openStack
  17.  
  18. -- set up environment
  19. -- show msg
  20. -- palette "Navigator"
  21. -- show window "Message Watcher"
  22. -- show window "Variable Watcher"
  23.  
  24. zeroStack
  25.  
  26. go to card "  Intro1"
  27. visual effect dissolve slowly
  28. go to card "  intro2"
  29. visual effect dissolve very slowly
  30. go to card "  intro3"
  31. visual effect dissolve
  32. go to first card of bg "Frequencies"
  33.  
  34. set the highlight of bg button "change radio automatically" to false
  35.  
  36. InitSerialPort
  37. end openStack
  38.  
  39. on closeStack
  40. closeSerialPort
  41. pass closeStack
  42. end closeStack
  43.  
  44. on idle
  45. readFromRadio
  46. LookForErrors
  47. pass idle
  48. end idle
  49.  
  50. on lookForErrors
  51. if dataWaiting() Γëá false then
  52. put getfromstack () into line
  53. if line is "?;" then
  54. -- put "radio returned an error" into msg
  55. play "boing"
  56. else
  57. addtostack line
  58. end if
  59. end if
  60.  
  61. end lookForErrors
  62.  
  63.  
  64. -- These functions actually do things with the radio via the
  65. -- serial port. Should only do it if the radio is defined as
  66. -- active on the configuration card.
  67. --
  68. -- ALL serial port functions should be here.
  69.  
  70. -- verify radio is configured on.
  71. function UsingRS232
  72. return the  highlight of cd button "R5000 Attached" of card "Configuration"
  73. end UsingRS232
  74.  
  75. -- open and initialize the serial port
  76. on initSerialPort
  77. global returnStack
  78.  
  79. if UsingRS232() = true then
  80. killSport
  81. closeSPort
  82. wait 50
  83. configureSPort modemPort, autoWrapOff, stripControlsOn, stripOn,┬¼
  84. editOff, parityoff, stop20, baud4800, data8, CSTOutON, XOnOutOff, ┬¼
  85. linefeedOff,echoOFF
  86. setSPortbufferSize 10240
  87. put empty into returnStack
  88.  
  89. TurnOnRadio
  90.  
  91. sendToRadio "ID;"
  92. put false into gotIt
  93. put 0 into counter
  94. repeat until gotIt is true
  95. readFromRadio
  96. add one to counter
  97. if counter > 10 then
  98. answer "Radio is not answering. R5000 disabled." with "OK"
  99. set the highlight of cd button "R5000 Attached" ┬¼
  100. of card "Configuration" to false
  101. closeSerialPort
  102. put true into gotIt
  103. end if
  104. set cursor to busy
  105. if dataWaiting () Γëá false then
  106. put getFromStack () into line
  107. if line is not "ID005;"  then
  108. answer "Got unknown" & line & "from radio" ┬¼
  109. with "Try again" or "Disable"
  110. if it is "Disable" then
  111. set the highlight of cd button "R5000 Attached" ┬¼
  112. of card "Configuration" to false
  113. closeSerialPort
  114. else
  115. sendToRadio "ID;"
  116. put false into gotIt
  117. put 0 into counter
  118. end if
  119. else
  120. put true into gotIt
  121. sendToRadio "AI0;" -- disable autostatus
  122.  
  123. set lockscreen to true
  124. push card
  125. go to first card of bg "frequencies"
  126. sendToRadio "IF;"
  127. repeat until dataWaiting() Γëá false
  128. wait 1
  129. end repeat
  130. put getFromStack () into line
  131. if char 1 of line is "I" and char 2 of line is "F" then
  132. put char 31 of line into vfostatus
  133. clearradbuttons
  134. if vfostatus = 0 then
  135. set the highlight of bg button "VFO A" to true
  136. set the visible of bg button "Load VFO" to true
  137. set the visible of bg button "Memup" to false
  138. set the visible of bg button "MemDN" to false
  139. else  if vfostatus = 1 then
  140. set the highlight of bg button "VFO B" to true
  141. set the visible of bg button "Load VFO" to true
  142. set the visible of bg button "Memup" to false
  143. set the visible of bg button "MemDN" to false
  144. else if vfostatus = 2 then
  145. set the highlight of bg button "Memory" to true
  146. set the visible of bg button "Load VFO" to false
  147. set the visible of bg button "Memup" to true
  148. set the visible of bg button "MemDN" to true
  149. end if
  150. else
  151. answer "got wrong data from IF" with "oops"
  152. end if
  153. pop card
  154. set lockscreen to false
  155.  
  156. setTime
  157. end if
  158. end if
  159. end repeat
  160. end if
  161. end initSerialPort
  162.  
  163. on clearradbuttons
  164. set the highlight of bg button "VFO A" to false
  165. set the highlight of bg button "VFO B" to false
  166. set the highlight of bg button "Memory" to false
  167. end clearradbuttons
  168.  
  169.  
  170. -- close the serial port
  171. on closeSerialPort
  172. if UsingRS232() = true then
  173. closeSPort
  174. end if
  175. end closeSerialPort
  176.  
  177. -- send something to the radio
  178. on sendToRadio string
  179. if UsingRS232() = true then
  180. sendSPort string
  181. end if
  182. end sendToRadio
  183.  
  184. -- get something from the radio
  185. on readFromRadio
  186. global fromRadio
  187.  
  188. if UsingRS232() = true then
  189. -- is there data in the port?
  190. if charsAvailable() > 0 then
  191. -- yes, suck it out and stick it somewhere for processing
  192. put recvUpTo(empty,0,empty) after fromRadio
  193. end if
  194.  
  195. -- the second phase. If it's a complete command (i.e. terminated
  196. -- with a ";") then take that part and throw it on the return
  197. -- stack. Have to do it this way because you might only read
  198. -- a partial command during one pass, so keep grabbing data until
  199. -- it's complete.
  200. put offset (";", fromRadio) into holder
  201. if holder > 0 then
  202. put char 1 to holder of fromRadio into gotBack
  203. addToStack gotBack
  204. delete char 1 to holder of fromRadio
  205. end if
  206. end if
  207. end readFromRadio
  208.  
  209. -- functions to handle the radio data stack.
  210. --
  211. -- the global returnStack is a FIFO stack that stores a list of
  212. -- data items returned from the radio for processing. If there's
  213. -- nothing pending, it's empty.
  214.  
  215. on zeroStack
  216. global returnStack
  217. put empty into returnStack
  218. end zeroStack
  219.  
  220. on addToStack string
  221. global returnStack
  222.  
  223. put string & return after returnStack
  224. end addToStack
  225.  
  226. function getFromStack
  227. global returnStack
  228.  
  229. if returnStack is empty then
  230. return empty
  231. else
  232. put line 1 of returnStack into string
  233. delete line one of returnStack
  234. return string
  235. end if
  236. end getFromStack
  237.  
  238. function dataWaiting
  239. global returnStack
  240.  
  241. readFromRadio
  242. global returnStack
  243.  
  244. if returnStack is empty then
  245. return false
  246. else
  247. return the number of lines in returnStack
  248. end if
  249. end dataWaiting
  250.  
  251. -- end of radio stack functions
  252.  
  253. -- These are the functions that actually control the radio.
  254.  
  255. -- lockKnob on|off (enable|disable tuning knob)
  256. on lockKnob value
  257. if value is empty then
  258. answer "usage: LockKnob on|off" with "okay"
  259. else if value is "on" then
  260. sendToRadio "LK1;"
  261. else if value is "off" then
  262. sendToRadio "LK0;"
  263. else
  264. answer "lockKnob: illegal value " &  value with "oops"
  265. end if
  266. end lockKnob
  267.  
  268. -- goUp (memory up)
  269. -- goDown (memory down)
  270. on goUp
  271. sendToRadio "UP;"
  272. end goUp
  273.  
  274. on goDown
  275. sendToRadio "DN;"
  276. end goDown
  277.  
  278. -- modeSelect lsb|usb|cw|fm|am|fsk
  279. on modeselect mode
  280. if mode is empty then
  281. answer "Usage: modeSelect lsb|usb|cw|fm|am|fsk" with "Okay"
  282. else if mode is "lsb" then
  283. sendToRadio "MD1;"
  284. else if mode is "usb" then
  285. sendToRadio "MD2;"
  286. else if mode is "cw" then
  287. sendToRadio "MD3;"
  288. else if mode is "fm" then
  289. sendToRadio "MD4;"
  290. else if mode is "am" then
  291. sendToRadio "MD5;"
  292. else if mode is "fsk" then
  293. sendToRadio "MD6;"
  294. else
  295. answer "modeSelect: illegal mode " & mode with "oops"
  296. end if
  297. end modeSelect
  298.  
  299. -- vfoSelect a|b|mem
  300. on vfoSelect value
  301. if value is empty then
  302. answer "Usage: vfoSelect a|b|mem" with "Okay"
  303. else if value is "a" then
  304. sendtoradio "FN0;"
  305. else if value is "b" then
  306. sendToRadio "FN1;"
  307. else if value is "mem" then
  308. sendToRadio "FN2;"
  309. else
  310. answer "vfoSelect: illegal value " & value with "oops"
  311. end if
  312. end vfoSelect
  313.  
  314. -- chooseMem nn (nn = 0 to 99)
  315. on chooseMem nn
  316. if nn is empty then
  317. answer "usage: chooseMem nn" with "okay"
  318. else if nn >= 0 and nn <= 99 then
  319. put numberformat into hold
  320. set numberFormat to 00
  321. add 0 to nn
  322. put "MC0" & nn & ";" into cmd
  323. sendToRadio cmd
  324. set numberformat to hold
  325. else
  326. answer "chooseMem: illegal value " & nn with "oops"
  327. end if
  328. end chooseMem
  329.  
  330. -- setFreq A|B freq
  331. on setFreq setwhich, khz
  332. if setwhich is empty or khz is empty then
  333. answer "Usage setFreq A|B|nn khz" with "Okay"
  334. exit setFreq
  335. end if
  336. put the round of (khz * 1000) into khz
  337. set the numberformat to "00000000000"
  338. if setwhich is "a" then
  339. sendToRadio "FA" & khz & ";"
  340. else if setwhich is "b" then
  341. sendToRadio "FB" & khz & ";"
  342. else
  343. answer "setwhich: illegal value " & setwhich with "oops"
  344. end if
  345. end setFreq
  346.  
  347. -- setmem nn freq mode
  348. -- nn is 0 - 99
  349. -- freq is as in setVFO
  350. -- mode is as in modeSelect
  351. on setMem nn, freq, mode
  352.  
  353. if nn is empty or freq is empty or mode is empty then
  354. answer "usage: setmem nn, freq, mode" with "okay"
  355. exit setMem
  356. end if
  357.  
  358. if nn < 0 or nn > 99 then
  359. answer "setmem: nn must be 0 - 99"
  360. exit setMem
  361. end if
  362.  
  363. if nn <= 9 then
  364. put "0" & nn into nn
  365. end if
  366.  
  367. -- converts this to a string to protect it from
  368. -- the upcoming numberFormat
  369. put nn & "" into nn
  370.  
  371. if mode is empty then
  372. answer "setMem: mode is lsb|usb|cw|fm|am|fsk" with "Okay"
  373. else if mode is "lsb" then
  374. put "1" into modeVal
  375. else if mode is "usb" then
  376. put "2" into modeVal
  377. else if mode is "cw"  then
  378. put "3" into modeVal
  379. else if mode is "fm" then
  380. put "4" into modeVal
  381. else if mode is "am"  then
  382. put "5" into modeVal
  383. else if mode is "fsk"  then
  384. put "6" into modeVal
  385. else
  386. answer "setMem: illegal mode " & mode with "oops"
  387. end if
  388.  
  389. put the round of (freq * 1000) into freq
  390. set the numberformat to "00000000000"
  391.  
  392. put "MW00" & nn & freq & modeVal & "00000;" into toRadio
  393. sendToRadio toRadio
  394.  
  395. end setMem
  396.  
  397. -- clearmem nn
  398. -- zap a memory
  399. on clearmem nn
  400. if nn < 0 or nn > 99 then
  401. answer "usage: clearmem nn"
  402. exit clearmem
  403. else
  404. if nn <= 9 then
  405. put "0" & nn into nn
  406. end if
  407.  
  408. sendtoradio "MW00" & nn & "00000000000000000;"
  409. end if
  410. end clearmem
  411.  
  412. -- getmem nn
  413. -- returns string "freq, mode" or empty
  414. function getmem nn
  415. if nn < 0 or nn > 99 then
  416. answer "usage: clearmem nn"
  417. exit getmem
  418. end if
  419.  
  420. if nn <= 9 then
  421. put "0" & nn into nn
  422. end if
  423.  
  424. sendToRadio "MR00" & nn & ";"
  425. put false into  foo
  426. put 0 into counter
  427. repeat while foo is false
  428. add one to counter
  429. if datawaiting() Γëá false then
  430. put getFromStack() into line
  431. if char 1 of line Γëá "M" and char 2 of line Γëá "R" then
  432. answer "radio sent back something weird" & cr & line with "oops"
  433. return empty
  434. end if
  435. if char 5 to 6 of line Γëá nn then
  436. answer "radio sent back wrong memory" & cr & line with "oops"
  437. return empty
  438. end if
  439.  
  440. put char 7 to 17 of line into freq
  441. put freq / 1000 into freq
  442. if freq = 0 then
  443. return empty
  444. end if
  445.  
  446. put char 18 of line into mode
  447. if mode = 1 then
  448. put "LSB" into mode
  449. else if mode = 2 then
  450. put "USB" into mode
  451. else if mode = 3 then
  452. put "CW" into mode
  453. else if mode = 4 then
  454. put "FM" into mode
  455. else if mode = 5 then
  456. put "AM" into mode
  457. else if mode = 6 then
  458. put "FSK" into mode
  459. else
  460. answer "illegal mode value in getmem" with "oops"
  461. return empty
  462. end if
  463.  
  464. return freq & ", " & mode
  465. end if
  466. if counter > 10 then
  467. return empty
  468. end if
  469. end repeat
  470. end getmem
  471.  
  472. on turnOnRadio
  473. sendToRadio "PS1;"
  474. end turnOnRadio
  475.  
  476. on turnOffRadio
  477. sendToRadio "PS0;"
  478. end turnOffRadio
  479.  
  480. on setUTCTime which
  481. if which is empty then
  482. answer "usage: setUTCTime 1|2" with "okay"
  483. exit setUTCTime
  484. else if which < 1 or which > 2 then
  485. answer "setUTCTime: illegal value " & which with "oops"
  486. exit setUTCTime
  487. end if
  488. put "" & which into which -- protects from numberFormat
  489.  
  490. put the seconds into now
  491. put bkgnd field "UTC" of card  "configuration" into offset
  492. put offset * 60 * 60 into offset -- convert to seconds
  493. put now + offset into now
  494. convert now to dateitems
  495. put the numberformat into hold
  496. set the numberformat to "00"
  497. put item 4 of now into hour
  498. add 0 to hour
  499. put item 5 of now into minutes
  500. add 0 to minutes
  501. put "CK" & which & hour & minutes & "00;" into string
  502. sendToRadio string
  503. set the numberformat to hold
  504. end setUTCTime
  505.  
  506. on setLocalTime which
  507. if which is empty then
  508. answer "usage: setLocalTime 1|2" with "okay"
  509. exit setLocalTime
  510. else if which < 1 or which > 2 then
  511. answer "setLocalTime: illegal value " & which with "oops"
  512. exit setLocalTime
  513. end if
  514. put "" & which into which -- protects from numberFormat
  515.  
  516. put the seconds into now
  517. convert now to dateitems
  518. put the numberformat into hold
  519. set the numberformat to "00"
  520. put item 4 of now into hour
  521. add 0 to hour
  522. put item 5 of now into minutes
  523. add 0 to minutes
  524. put "CK" & which & hour & minutes & "00;" into string
  525. sendToRadio string
  526. set the numberformat to hold
  527. end setLocalTime
  528.  
  529. on setTime
  530. if usingRS232() is true then
  531. if the highlight of cd button "Clock 1"  ┬¼
  532. of card "configuration" is true then
  533. put 1 into which
  534. else if the highlight of cd button "Clock 2" ┬¼
  535. of card "configuration" is true then
  536. put 2 into which
  537. else
  538. exit setTime
  539. end if
  540. if which is 1 then
  541. setUTCtime 1
  542. setLocalTime 2
  543. else
  544. setUTCtime 2
  545. setLocalTime 1
  546. end if
  547. end if
  548. end setTime
  549.  
  550. on